package com.mz.ozy.widget;

import android.app.Activity;
import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;

import com.github.penfeizhou.animation.apng.APNGDrawable;
import com.github.penfeizhou.animation.loader.AssetStreamLoader;
import com.mz.ozy.R;
import com.mz.ozy.widget.dialog.BaseDialog;

public class LoadingDialog extends BaseDialog {

    private APNGDrawable apngDrawable;

    public LoadingDialog(Activity mContext) {
        super(mContext, R.layout.dialog_load_ing, Gravity.CENTER, true, false, true);
        initView();
    }

    private void initView() {
        ImageView ivLoading = getView(R.id.iv_loading);
        AssetStreamLoader assetLoader = new AssetStreamLoader(mContext, "spla_loading.png");
        apngDrawable = new APNGDrawable(assetLoader);
        ivLoading.setImageDrawable(apngDrawable);
        apngDrawable.setLoopLimit(-1);
    }

    public void showLoading() {
        showDialog();
    }

    public void dismissLoading() {
        dismissDialog();
    }
}
